{% extends "blog/admin/base.html" %}
{% block title %}Admin: View All Posts{% endblock %}
{% block body %}
<div class="block index-list">
	<div class="hd">
  		<h2>Admin: View All Posts</h2>
	</div>
	<div class="bd">
		{% if last_post != -1 %}
		<div>Posts {{offset + 1}} to {{last_post + 1}}</div>
		<div class="yui-gc list-header">
			<div class="yui-u first">
				Title
			</div>
			<div class="yui-g">
				<div class="yui-u first">
					Published
				</div>
				<div class="yui-u">
					Actions
				</div>
			</div>
		</div>
		{% set row_class = cycler('odd', 'even') %}
		{% for post in posts %}
		<div class="yui-gc list-item {{ row_class.next() }}">
			<div class="yui-u first">
				<a href="{{ url_for('blog/post', post_id=post.key().id()) }}">{{post.title|e}}</a>
			</div>
			<div class="yui-g">
				<div class="yui-u first">
					{% if post.path %}{{post.published|date("%d %b, %Y")}}{% else %}Draft{% endif %}
				</div>
				<div class="yui-u">
				    {% if post.path %}
				      <a href="{{post.path}}">View</a>
				      |
				    {% endif %}
					<a href="{{ url_for('blog/post', post_id=post.key().id()) }}">Edit</a>

				</div>
			</div>
		</div>		
		{% endfor %}	
	  	{% else %}
	    <p>
	      No posts yet.<br />
	      <a href="/admin/newpost">Write your first post.</a>
	    </p>
	  {% endif %}
	</div>
	{% if offset != 0 or more_posts %}
	<div class="ft yui-g">
		<div class="yui-u first">
			{% if more_posts %}
			<a class="float-left" href="{{ url_for('blog/admin', start=next_offset, count=count) }}"> &#171; Older Posts </a>
			{% else %}
			&nbsp;
			{% endif %}
		</div>
		<div class="yui-u">
			{% if offset != 0 %}
			<a class="float-right" href="{{ url_for('blog/admin', start=prev_offset, count=count) }}"> Newer Posts &#187; </a>
			{% else %}
			&nbsp;
			{% endif %}
		</div>
	</div>
	{% endif %}
</div>
<div class="block form">
	<div class="hd">
 			<h2>Admin Actions</h2>
	</div>
	<div class="bd">
		<form method="post" action="{{ url_for('blog/regenerate') }}">
			<fieldset>
			  	<input id="btn_Regen" type="submit" value="Regenerate all posts" />
			</fieldset>
		</form>
	</div>
</div>
{% endblock %}
